package com.agv.backend.service.impl;

import com.agv.backend.entity.pojo.AgvConfig;
import com.agv.backend.mapper.AgvConfigMapper;
import com.agv.backend.service.AgvConfigService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class AgvConfigServiceImpl extends ServiceImpl<AgvConfigMapper,AgvConfig> implements AgvConfigService {

    private final AgvConfigMapper agvConfigMapper;

    public AgvConfigServiceImpl(AgvConfigMapper agvConfigMapper) {
        this.agvConfigMapper = agvConfigMapper;
    }

    @Override
    public AgvConfig getConfig() {
        return agvConfigMapper.selectOne(new LambdaQueryWrapper<AgvConfig>().last("LIMIT 1"));
    }

    @Override
    public int updateConfig(AgvConfig agvConfig) {
        return agvConfigMapper.updateById(agvConfig);
    }
}